# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo1762
# Description:  greenlet模块实现程序间切换执行
# Author:       yzl
# Date:         2019-03-11
#-------------------------------------------------------------------------------

import greenlet

def A():
    print('a.....')
    g2.switch()  #切换至B
    print('a....2')
    g2.switch()

def B():
    print('b.....')
    g1.switch()  #切换至A
    print('b....2')

g1 = greenlet.greenlet(A) #启动一个线程
g2 = greenlet.greenlet(B)
g1.switch()

